
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
base plugin that provides a very thin wrapper around <https://github.com/doowb/composer> for adding task methods to your application.
base plugin that provides a very thin wrapper around https://github.com/doowb/composer for adding task methods to your application.
You might also be interested in base-watch.
Install with npm:
$ npm install base-task --save
var Base = require('base-methods');
var tasks = require('base-task');
Base.use(tasks());
var base = new Base();
base.task('foo', function(cb) {
console.log('this is foo!');
cb();
});
base.task('bar', function(cb) {
console.log('this is bar!');
cb();
});
base.build(['foo', 'bar'], function(err) {
// this is foo!
// this is bar!
console.log('done!');
});
See the composer documentation for more details, or to create bug reports related to running or registering tasks.
Register a task
Params
name
{String}: Task name to register (tasks are cached on app.tasks
)dependencies
{String|Array|Function}: String, list or array of tasks.callback
{Function}: Function to be called when the task is executed. Task functions should either return a stream or call the callback to let composer know when the task is finished.Examples
Register a task.
app.task('default', function() {
// return the stream to signal "done"
return app.src('pages/*.hbs')
.pipe(app.dest('dist'));
});
Register a task with dependencies (other tasks to run before executing the task):
app.task('site', ['styles'], function() {
return app.src('pages/*.hbs')
.pipe(app.dest('dist'));
});
app.task('default', ['site']);
Get a task
var task = app.task('site');
Run a task or array of tasks.
Example
app.build('default', function(err, results) {
if (err) {
console.error(err);
return;
}
console.log(results);
});
Compose task or list of tasks into a single function that runs the tasks in series.
Params
tasks
{String|Array|Function}: List of tasks by name, function, or array of names/functions.returns
{Function}: Composed function that may take a callback function.Example
app.task('foo', function(cb) {
console.log('this is foo');
cb();
});
var fn = app.series('foo', function(cb) {
console.log('this is bar');
cb();
});
fn(function(err) {
if (err) return console.error(err);
console.log('finished');
});
//=> this is foo
//=> this is bar
//=> finished
Compose task or list of tasks into a single function that runs the tasks in parallel.
Params
tasks
{String|Array|Function}: List of tasks by name, function, or array of names/functions.returns
{Function}: Composed function that may take a callback function.Example
app.task('foo', function(cb) {
setTimeout(function() {
console.log('this is foo');
cb();
}, 500);
});
var fn = app.parallel('foo', function(cb) {
console.log('this is bar');
cb();
});
fn(function(err) {
if (err) return console.error(err);
console.log('finished');
});
//=> this is bar
//=> this is foo
//=> finished
The following events are emitted by composer. See the composer docs for more details
Emitted when a build
is starting.
app.on('starting', function(app, build) {});
The event emits 2 arguments:
app
andbuild
runtime information:.date
: an object with the .start
time as a Date
object..hr
: an object with the .start
time as an hrtime
array.Emitted when a build
is finished.
app.on('finished', function(app, build) {});
The event emits 2 arguments:
app
: instance of composerbuild
: an object with build runtime information:.date
: object with .start
and .end
properties, with staring and ending times of the build as Date
objects..hr
: object with .start
, .end
, .duration
, and .diff
properties with timing information calculated using process.hrtime
Emitted when an error occurrs during a build
.
app.on('error', function(err) {});
Emitted when a task is starting.
app.on('task:starting', function(task, run) {});
Emitted when a task has finished.
app.on('task:finished', function(task, run) {});
Emitted when an error occurrs while running a task.
app.on('task:error', function(err) {});
v0.3.0
.watch
method is no longer included by default. To add .watch
, use the base-watch plugin.Other base plugins you might be interested in:
base
application. | homepageoption
, enable
and disable
. See the readme… more | homepagePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Generate readme and API documentation with [verb][]:
$ npm install verb && npm run docs
Or, if [verb][] is installed globally:
$ verb
Install dev dependencies:
$ npm install -d && npm test
Jon Schlinkert
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on May 11, 2016.
FAQs
Base plugin that provides a very thin wrapper around <https://github.com/doowb/composer> for adding task methods to your Base application.
The npm package base-task receives a total of 25,828 weekly downloads. As such, base-task popularity was classified as popular.
We found that base-task demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.